package fit.deni.components;

import java.util.List;

import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import fit.deni.beans.Telefon;
import fit.deni.hibernate.interfaces.TelefonService;

public class AddPhone {
	
	@Property
	@Parameter(required = true)
	private List<Telefon> phones;
	@Property
	private Telefon phone;
	@Property
	@Persist
	private String phoneFixTF, phoneMobTF;
	
	@Inject
	private TelefonService telefonService;
	
	public void onAddPhone() {
		Telefon t = new Telefon();
		t.setFiksni(phoneFixTF);
		t.setMobilni(phoneMobTF);
		phoneFixTF = "";
		phoneMobTF = "";
		phones.add(t);
//		telefonService.addPhone(t);
	}
	
	public void onRemovePhone(Object p) {
		Telefon t = (Telefon) p;
		phones.remove(t);
	}
	
}
